package com.yy.controller;


import com.github.pagehelper.PageInfo;
import com.yy.domain.ResponseResult;
import com.yy.domain.SecondHospitalAppointmentsDO;
import com.yy.dto.mother.*;
import com.yy.service.SecondHospitalAppointmentsService;
import com.yy.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 姚欣宏
 * @since 2023-10-24
 */
@RestController
@RequestMapping("/api/v1/second-hospital")
@Api(tags = "企康-华西附二院相关接口")
public class SecondHospitalAppointmentsController {

    private final SecondHospitalAppointmentsService secondHospitalAppointmentsService;

    public SecondHospitalAppointmentsController(SecondHospitalAppointmentsService secondHospitalAppointmentsService) {
        this.secondHospitalAppointmentsService = secondHospitalAppointmentsService;
    }


    @GetMapping("/get-authcode")
    @ApiOperation(value = "获取手机验证码")
    public ResponseResult<AuthDataDTO> getAuthCode(
            @ApiParam(value = "手机号码", required = true)
            @RequestParam String phoneNum) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.getAuthCode(phoneNum));
    }


    @PostMapping("/tasks/create")
    @ApiOperation("创建任务")
    public ResponseResult<Integer> tasksCreate(@RequestBody AppointmentTasksVO appointmentTasksVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.tasksCreate(appointmentTasksVO));
    }


    @PostMapping("/tasks/list")
    @ApiOperation("任务列表")
    public ResponseResult<PageInfo<SecondHospitalAppointmentsDO>> tasksList(@RequestBody AppointmentTasksPageVO appointmentTasksPageVO) {
        PageInfo<SecondHospitalAppointmentsDO> pageInfo = secondHospitalAppointmentsService.tasksList(appointmentTasksPageVO);
        return new ResponseResult<>(200, "请求成功", pageInfo);
    }

    @PostMapping("/user-organ-cards")
    @ApiOperation(value = "获取用户的机构卡片列表")
    public ResponseResult<List<UserOrganCardDetailDTO>> getUserOrganCardList(@RequestBody CardRequestVO cardRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.getUserOrganCardList(cardRequestVO));
    }

    @PostMapping("/sel-tree")
    @ApiOperation(value = "科室预约分类树")
    public ResponseResult<DepartmentInfoDTO> selTree(@RequestBody TreeRequestVO treeRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.selTree(treeRequestVO));
    }

    @PostMapping("/sel-doc-list")
    @ApiOperation(value = "预约医生选择列表接口")
    public ResponseResult<DetailedDataResponseDTO> selDocListSelectionPage(@RequestBody TreeRequestVO treeRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.selDocListSelectionPage(treeRequestVO));
    }

    @PostMapping("/sel-doctor-list")
    @ApiOperation(value = "预约医生分页列表接口")
    public ResponseResult<PageDoctorResponseDTO> selDoctorListPaging(@RequestBody DoctorRequestVO doctorRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.selDoctorListPaging(doctorRequestVO));
    }

    @ApiOperation("配置任务")
    @PostMapping("/task/configuration")
    public ResponseResult<Integer> taskConfiguration(@RequestBody AppointmentTasksVO appointmentTasksVO) {
        Integer id = secondHospitalAppointmentsService.taskConfiguration(appointmentTasksVO);
        return new ResponseResult<>(200, "请求成功", id);
    }

    @PostMapping("/sel-doctor-schedule")
    @ApiOperation(value = "预约医生日程查询接口")
    public ResponseResult<DataResponseDTO> selDoctorSchedule(@RequestBody DoctorInfoRequestVO doctorInfoRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.selDoctorSchedule(doctorInfoRequestVO));
    }

    @PostMapping("/sel-sure-order")
    @ApiOperation(value = "预约确认订单页面接口")
    public ResponseResult<DoctorDetailDTO> selSureOrderPage(@RequestBody ScheduleInfoRequestVO scheduleInfoRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.selSureOrderPage(scheduleInfoRequestVO));
    }

    @PostMapping("/order-check")
    @ApiOperation(value = "预约订单检查接口")
    public ResponseResult<AppointmentResponseDTO> orderCheck(@RequestBody AppointmentRequestVO appointmentRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.orderCheck(appointmentRequestVO));
    }

    @PostMapping("/get-image-code")
    @ApiOperation(value = "获取图像验证码接口")
    public ResponseResult<ImageCodeDTO> getImageCode(@RequestBody ImageRequestVO imageRequestVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.getImageCode(imageRequestVO));
    }

    @PostMapping("/sure-order")
    @ApiOperation(value = "确认订单")
    public ResponseResult<DetailResponseDTO> sureOrder(@RequestBody InformationVO informationVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.sureOrder(informationVO));
    }

    @PostMapping("/record-page")
    @ApiOperation(value = "挂号记录")
    public ResponseResult<PatientPageInfoDTO> recordPage(@RequestBody QueryCriteriaVO queryCriteriaVO) {
        return new ResponseResult<>(200, "请求成功", secondHospitalAppointmentsService.recordPage(queryCriteriaVO));
    }

    @PostMapping("/cancel")
    @ApiOperation(value = "取消订单")
    public ResponseResult<Void> cancel(@RequestBody CancelVO cancelVO) {
        secondHospitalAppointmentsService.cancel(cancelVO);
        return new ResponseResult<>(200, "请求成功");
    }

    @ApiOperation("复制")
    @GetMapping("/copy")
    public ResponseResult<Void> copy(@RequestParam Integer id) {
        secondHospitalAppointmentsService.copy(id);
        return new ResponseResult<>(200, "请求成功");
    }

    @ApiOperation("校验token是否有效")
    @GetMapping("/check-token")
    public ResponseResult<String> checkToken(@RequestParam Integer id) {
        String checkToken = secondHospitalAppointmentsService.checkToken(id);
        return new ResponseResult<>(200, "请求成功", checkToken);
    }

}

